cmake_minimum_required(VERSION 3.5) # CMake install : https://cmake.org/download/
project(MyProject LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_PREFIX_PATH "d:/Application/Qt/6.7.3/llvm-mingw_64") # Qt Kit Dir
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 COMPONENTS Widgets REQUIRED) # Qt COMPONENTS
aux_source_directory(./src srcs)

# Specify MSVC UTF-8 encoding   
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

add_executable(${PROJECT_NAME}
    WIN32 # If you need a terminal for debug, please comment this statement 
    ${srcs} 
) 
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets) # Qt6 Shared Library

# 添加自定义命令来复制文件到顶层CMakeLists.txt的bin目录
add_custom_command(TARGET MyProject POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy
            "$<TARGET_FILE:MyProject>"
            "${PROJECT_SOURCE_DIR}/bin/${CMAKE_PROJECT_NAME}.exe"
)

# 添加自定义命令来指定生成完毕的QT程序
add_custom_command(TARGET MyProject POST_BUILD
    COMMAND "${PROJECT_SOURCE_DIR}/bin/${CMAKE_PROJECT_NAME}.exe"
)
